package com.ceair.flight.refund.dto.appmoblie;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

public class RefundSegDto implements Comparable<com.ceair.flight.refund.dto.appmoblie.RefundSegDto>, Serializable {

    private static final long serialVersionUID = 8257246200854234704L;

    private long id;
    private RefundTktDto refundTkt;
    private String departAirport;
    private String arriveAirport;
    private Date departDate;
    private Date arriveDate;
    private String status;
    private String cabin;
    private String fareBaise;
    private String flightNo;
    private String realFlightNo;
    private int indexNo;
    private String segType;
    private String flightStatus;
    private String eiContent;
    private BigDecimal ticketPrice;
    private BigDecimal salePrice;
    private String refundRule;
    private String realRefundRule;
    private BigDecimal refundFee;
    private BigDecimal refundAmount;
    private Boolean isReschedule;
    private BigDecimal rescheduleTktGap;
    private BigDecimal rescheduleFee;
    private BigDecimal rescheduleFeeRes;
    private Long segPoints;
    private Long refundPoints;
    private Set<RefundTaxDto> refundTaxes = new HashSet<>(0);
    private BigDecimal fcnyDiff;
    private BigDecimal scnyDiff;
    private BigDecimal fcnyDiffRes;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public RefundTktDto getRefundTkt() {
        return refundTkt;
    }

    public void setRefundTkt(RefundTktDto refundTkt) {
        this.refundTkt = refundTkt;
    }

    public String getDepartAirport() {
        return departAirport;
    }

    public void setDepartAirport(String departAirport) {
        this.departAirport = departAirport;
    }

    public String getArriveAirport() {
        return arriveAirport;
    }

    public void setArriveAirport(String arriveAirport) {
        this.arriveAirport = arriveAirport;
    }

    public Date getDepartDate() {
        return departDate;
    }

    public void setDepartDate(Date departDate) {
        this.departDate = departDate;
    }

    public Date getArriveDate() {
        return arriveDate;
    }

    public void setArriveDate(Date arriveDate) {
        this.arriveDate = arriveDate;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getCabin() {
        return cabin;
    }

    public void setCabin(String cabin) {
        this.cabin = cabin;
    }

    public String getFareBaise() {
        return fareBaise;
    }

    public void setFareBaise(String fareBaise) {
        this.fareBaise = fareBaise;
    }

    public String getFlightNo() {
        return flightNo;
    }

    public void setFlightNo(String flightNo) {
        this.flightNo = flightNo;
    }

    public String getRealFlightNo() {
        return realFlightNo;
    }

    public void setRealFlightNo(String realFlightNo) {
        this.realFlightNo = realFlightNo;
    }

    public int getIndexNo() {
        return indexNo;
    }

    public void setIndexNo(int indexNo) {
        this.indexNo = indexNo;
    }

    public String getSegType() {
        return segType;
    }

    public void setSegType(String segType) {
        this.segType = segType;
    }

    public String getFlightStatus() {
        return flightStatus;
    }

    public void setFlightStatus(String flightStatus) {
        this.flightStatus = flightStatus;
    }

    public String getEiContent() {
        return eiContent;
    }

    public void setEiContent(String eiContent) {
        this.eiContent = eiContent;
    }

    public BigDecimal getTicketPrice() {
        return ticketPrice;
    }

    public void setTicketPrice(BigDecimal ticketPrice) {
        this.ticketPrice = ticketPrice;
    }

    public BigDecimal getSalePrice() {
        return salePrice;
    }

    public void setSalePrice(BigDecimal salePrice) {
        this.salePrice = salePrice;
    }

    public String getRefundRule() {
        return refundRule;
    }

    public void setRefundRule(String refundRule) {
        this.refundRule = refundRule;
    }

    public String getRealRefundRule() {
        return realRefundRule;
    }

    public void setRealRefundRule(String realRefundRule) {
        this.realRefundRule = realRefundRule;
    }

    public BigDecimal getRefundFee() {
        return refundFee;
    }

    public void setRefundFee(BigDecimal refundFee) {
        this.refundFee = refundFee;
    }

    public BigDecimal getRefundAmount() {
        return refundAmount;
    }

    public BigDecimal getRefundAmountIncludeTax() {
        BigDecimal result = this.getRefundTax();
        if (refundAmount != null) {
            result = result.add(refundAmount);
        }
        return result;
    }

    public void setRefundAmount(BigDecimal refundAmount) {
        this.refundAmount = refundAmount;
    }

    public Boolean getIsReschedule() {
        return isReschedule;
    }

    public void setIsReschedule(Boolean isReschedule) {
        this.isReschedule = isReschedule;
    }

    public BigDecimal getRescheduleTktGap() {
        return rescheduleTktGap;
    }

    public void setRescheduleTktGap(BigDecimal rescheduleTktGap) {
        this.rescheduleTktGap = rescheduleTktGap;
    }

    public BigDecimal getRescheduleFee() {
        return rescheduleFee;
    }

    public void setRescheduleFee(BigDecimal rescheduleFee) {
        this.rescheduleFee = rescheduleFee;
    }

    public Set<RefundTaxDto> getRefundTaxes() {
        return refundTaxes;
    }

    public BigDecimal getRefundTax() {
        BigDecimal result = BigDecimal.ZERO;
        if (refundTaxes != null) {
            for (RefundTaxDto tax : refundTaxes) {
                BigDecimal refundValue = tax.getRefundValue();
                if (refundValue != null) {
                    result = result.add(refundValue);
                }
            }
        }
        return result;
    }

    public Set<RefundTaxDto> getViewRefundTaxes() {
        //国际航线票,税费只在一个航段上
        if (refundTkt != null && refundTkt.isInterAirline() && isAllZero()) {
            return Collections.EMPTY_SET;
        }
        return refundTaxes;
    }

    private boolean isAllZero() {
        if (refundTaxes != null) {
            for (RefundTaxDto tax : refundTaxes) {
                BigDecimal taxValue = tax.getOrignalValue();
                if (taxValue != null && taxValue.compareTo(BigDecimal.ZERO) > 0) {
                    return false;
                }
            }
        }
        return true;
    }

    public void setRefundTaxes(Set<RefundTaxDto> refundTaxes) {
        this.refundTaxes = refundTaxes;
    }

    public Long getSegPoints() {
        return segPoints;
    }

    public void setSegPoints(Long segPoints) {
        this.segPoints = segPoints;
    }

    public Long getRefundPoints() {
        return refundPoints;
    }

    public void setRefundPoints(Long refundPoints) {
        this.refundPoints = refundPoints;
    }
    
    public BigDecimal getFcnyDiff() {
		return fcnyDiff;
	}

	public void setFcnyDiff(BigDecimal fcnyDiff) {
		this.fcnyDiff = fcnyDiff;
	}

	public BigDecimal getScnyDiff() {
		return scnyDiff;
	}

	public void setScnyDiff(BigDecimal scnyDiff) {
		this.scnyDiff = scnyDiff;
	}
	
	public BigDecimal getFcnyDiffRes() {
		return fcnyDiffRes;
	}

	public void setFcnyDiffRes(BigDecimal fcnyDiffRes) {
		this.fcnyDiffRes = fcnyDiffRes;
	}

	public BigDecimal getRescheduleFeeRes() {
		return rescheduleFeeRes;
	}

	public void setRescheduleFeeRes(BigDecimal rescheduleFeeRes) {
		this.rescheduleFeeRes = rescheduleFeeRes;
	}

	@Override
    public int compareTo(com.ceair.flight.refund.dto.appmoblie.RefundSegDto dest) {
        return this.indexNo - dest.indexNo;
    }

	@Override
	public boolean equals(Object obj) {
		// TODO Auto-generated method stub
		return super.equals(obj);
	}

    @Override
    public int hashCode() {
        return super.hashCode();
    }
}
